package com.obrempon.credit.market.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.obrempon.credit.market.ObremponApp
import com.obrempon.credit.market.R
import com.obrempon.credit.market.weight.font.RobotoMediumTextView
import com.obrempon.module.adapter.ObremponRecyclerViewAdapter
import com.obrempon.module.adapter.ObremponViewHolderHelper
import org.json.JSONObject

/**
 * ObremponCredit
 * @Author wwdeng
 * @CreateTime: 2025/3/10 18:43
 * @Annotation：出生年月 - 日
 */
class ObremponBirthdayDayApt(recyclerView: RecyclerView?) : ObremponRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.obrempon_birthday_dialog_day_item) {
    override fun setItemChildListener(helper: ObremponViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.textDay) //点击Item
    }
    override fun fillData(helper: ObremponViewHolderHelper, position: Int, model: JSONObject) {
        val textDay = helper.getView<RobotoMediumTextView>(R.id.textDay)
        val showDay = model.optInt("day")
        if (showDay == 0){
            textDay.text = ""
        } else {
            textDay.text = "$showDay"
        }

        if (model.optBoolean("isSelect")){
            textDay.typeface = ObremponApp.app.getBoldTypeface()
            textDay.setTextColor(getColor(R.color.white))
            textDay.shapeDrawableBuilder.setSolidColor(getColor(R.color.color_ff0569ff)).intoBackground()
        } else {
            textDay.typeface = ObremponApp.app.getMediumTypeface()
            textDay.setTextColor(getColor(R.color.black))
            textDay.shapeDrawableBuilder.setSolidColor(getColor(R.color.transparent)).intoBackground()
        }
    }
}